function generateConfirmTime(data) {
    if (!data.disposeTime) {
        data.disposeTime = "--:--"
    }
    if (data.flowLinkId == 1){
        return '<span class="p_time" style="color:black">' + data.answerTime + '</span>'
    }
    switch (data.statu) {
        case 2:
            return '<span class="p_contime" style="color:#FF5722">' + data.disposeTime + '(' + data.subTime + ') </span>'
            break;
        case 1:
            return '<span class="p_contime" style="color:black">' + data.disposeTime + '(' + data.subTime + ') </span>'
            break;
        case 0:
            return '<span class="p_contime" style="color:grey">' + data.disposeTime + '(' + data.subTime + ') </span>'
            break;
    }
};

function generateTime(data) {
    switch (data.statu) {
        case 2:
            return '<span class="p_time" style="color:#FF5722">' + data.answerTime + '</span>'
            break;
        case 1:
            return '<span class="p_time" style="color:black">' + data.answerTime + '</span>'
            break;
        case 0:
            return '<span class="p_time" style="color:grey">' + data.answerTime + '</span>'
            break;
    }
};

var majorNameMap = {
    9:'车辆',
    10:'供电',
    11:'通号',
    12:'工务',
    13:'物后'
}

var count = 0;

function generateFlowEvent(data) {
    if (data.flowLinkId == 1) {
        // return '<input type="text" class="flow_content" name="flow_test" value="' + data.faultContent + '"/>'
        // return '<span class="p_content" style="color:black">(' + majorNameMap[data.tag]+') ' +  data.faultContent + ' </span>'   
            return '<span class="p_content" style="color:black">' +  data.faultContent + ' </span>'
    } else {
        switch (data.statu) {
            case 2:
                return '<span class="p_content" style="color:#FF5722">(' + majorNameMap[data.tag]+') ' + data.flowName + '</span>'
                break;
            case 1:
                return '<span class="p_content" style="color:black">(' + majorNameMap[data.tag]+') ' + data.flowName + ' </span>'
                break;
            case 0:
                return '<span class="p_content" style="color:grey">(' + majorNameMap[data.tag]+') ' + data.flowName + ' </span>'
                break;
        }
    }
}

function generateToolBar(data) {
    if (data.statu == 2) {
        return '<a class="layui-btn layui-btn-sm" lay-event="sure">确认</a>'
    } else {
        return '<a class="layui-btn layui-btn-sm" lay-event="sure" style="display:none">确认</a>'
    }
}

function alertMsg(msg) {
    layer.open({
        type: 1
        , offset: 'auto' //具体配置参考：http://www.layui.com/doc/modules/layer.html#offset
        , id: 'layerDemoauto' //防止重复弹出
        , content: '<div style="padding: 20px 100px;">' + msg + '</div>'
        , btn: '关闭'
        , btnAlign: 'c' //按钮居中
        , shade: 0 //不显示遮罩
        , yes: function () {
            // layer.close(layer.index);
            layer.closeAll('page');
        }
    });
}

function closeSonPage() {
    var index = parent.layer.getFrameIndex(window.name);
    parent.layer.close(index);//关闭当前页
}


var flowData = {
    faultId : "",
    tag : "",
    faultTime: ""
};


function setFlowData(faultId,tag,faultTime){
    localStorage.setItem("faultId",faultId);
    localStorage.setItem("tag",tag);
    localStorage.setItem("faultTime",faultTime);
}

function getFlowData(){
    let flowData = {
        faultId : localStorage.getItem("faultId"),
        tag : localStorage.getItem("tag"),
        faultTime : localStorage.getItem("faultTime"),
    }
    return flowData;
}
var IPPort={
    ip : "localhost",
    port : "10110"
}
function getIP(){
    return "http://"+IPPort.ip+":"+IPPort.port;
}

function setValue(keyN,value){
    localStorage.setItem(keyN,value);
}

function getValue(keyN){
    return localStorage.getItem(keyN)
}

function generateLineStationInfo(){
    $.ajax({
        url: getIP()+'/fault/stationInfo',
        type: 'get',
        contentType: 'application/x-www-form-urlencoded',
        success: function (data) {
          if (data.code == 'success') {
           return data.data;
          }
        },
        complete: function () {
 
        },
      });
}

function generateLineNo($){
    $("#faultRoute").append('<option value="0">请选择</option>');
    $("#faultRoute").append('<option value="全网络">全网络</option>');
    for (let index = 0; index < line_no.length; index++) {
        const element = line_no[index];
        $("#faultRoute").append('<option value="'+ element  +'">'+ parseInt(element, 10) +'号线</option>');
    }
    layui.form.render("select");
}

function generateStation(line_no,$){
    $("#station").empty();
    if(line_no == 0){
        $("#station").append('<option value="">请先选择线路</option>');
    }else if(line_no == '全网络') {
        $("#station").append('<option value="全网络">全网络</option>');
    }else{
        var stationInfo = line_data[line_no-1].lineStationInfo;
        $("#station").append('<option value="">请选择</option>');
        for (let index = 0; index < stationInfo.length; index++) {
            const element = stationInfo[index];
            $("#station").append('<option value="'+element.station+'">'+ element.station +'</option>');
        }
    }
    layui.form.render("select");
}










